package com.jvup.common.dal.base;

public class ResponseWrapper {

    private boolean success;
    private Object data;
    private String msg;
    private int code;

    public boolean isSuccess() {
        return success;
    }

    public Object getData() {
        return data;
    }

    public String getMsg() {
        return msg;
    }

    public int getCode() {
        return code;
    }

    public boolean isIllegal(){
        return !isSuccess() || getCode() != 0;
    }

    /**
     * 该方法是当请求失败时调用，isIllegal返回true时，需要更具服务器返回的错误代码进行处理，或者是其他方式处理错误情况*/
    public void illegalExceptionHandle(String tagUrl){
        System.out.println("接口业务调用失败!"+getMsg()+",错误代码："+getCode()+",接口："+tagUrl);
    }


//    int errorCode = responseWrapper.getErrCode();
//            if(errorCode == com.qire.manhua.model.bean.ResponseWrapper.EC_NOT_LOGIN){   // 未登录
//        NotLoginException exception = new NotLoginException(tagUrl);
//        exception.requestUrl = tagUrl;
//        exception.extraMsg = responseWrapper.getMsg();
//        ExceptionObservable.notifyObservers(exception);
//    } else {        // 其它接口异常
//        NetApiException exception = new NetApiException(tagUrl);
//        exception.requestUrl = tagUrl;
//        exception.errorCode = errorCode;
//        exception.extraMsg = responseWrapper.getMsg();
//        ExceptionObservable.notifyObservers(exception);
//    }

}
